package com.jinzhi.jzweb.controller.yyrby;

import com.baomidou.mybatisplus.plugins.Page;
import com.jinzhi.common.utils.Result;
import com.jinzhi.jzweb.service.ExaminationResultsComService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * @author mengzhichao
 * @create 2024-04-12-16:53
 */
@Controller
@RequestMapping("/jzweb/ExaminationResultZqfz")
public class ExaminationResultZqfzController {
    @Autowired
    private ExaminationResultsComService examinationResultsService;

    /**
     * 统计最高分，最低分，总人数查询
     * @return
     */
    @ResponseBody
    @GetMapping("/listTopscoreAndLowestMark")
    @RequiresPermissions("jzweb:examinationAnswerSheetCom:examinationAnswerSheetComyuezi")
    public Result<Map> listTopscoreAndLowestMark(String field){
        return Result.ok(examinationResultsService.zqxxStatistics(field));
    }



    /**
     * 统计列表查询
     * @return
     */
    @ResponseBody
    @GetMapping("/list")
    @RequiresPermissions("jzweb:examinationAnswerSheetCom:examinationAnswerSheetComyuezi")
    public Result<Page<ScResultVO>> list(String field, int pageNumber, int pageSize){
        Page<ScResultVO> scResultVOPage = examinationResultsService.zqxxStatistics(field, pageNumber, pageSize);
        return Result.ok(scResultVOPage);
    }

    /**
     * 超级管理员 一级管理员查看分数
     * @param model
     * @return
     */
    @GetMapping()
    @RequiresPermissions("jzweb:examinationAnswerSheetCom:examinationAnswerSheetComyuezi")
    String info( Model model) {
        return "jzweb/examinationAnswerSheetComyuezi/examinationAnswerSheetComyuezi";
    }



    @GetMapping("/downloadImportZqfz")
    @RequiresPermissions("jzweb:examinationAnswerSheetComyuezi:import")
    @ResponseBody
    public void downloadImportTemplate(HttpServletResponse response, String field) {
        examinationResultsService.importZqfz(response,field);
    }


}
